#ifndef UI_ADDITIONAL_DATA
#define UI_ADDITIONAL_DATA

	// predef
	#include "UnityCG.cginc"
	#include "UnityUI.cginc"

	#include "Packages/com.devil.gametoolkit/Shaders/CGINC/HSVConverter.cginc"
	
	#if defined(_INTENSITY_ON) || defined(_DETAIL_MUL) || defined(_DETAIL_BLEND)
		#define TEXCOORD1_ON
	#endif
	
	#if defined(_SOFT_MASK) || defined(_DETAIL_MUL) || defined(_DETAIL_BLEND)
		#define MASK_ON
	#endif

	#if defined(_DETAIL_MUL) || defined(_DETAIL_BLEND)
		#define DETAIL_ON
	#endif
	
	// vf cal
	
	#if defined(_INTENSITY_ON)
		half4 _IntensitySample;
		float _IntensityShape;
	#endif

	#if defined(MASK_ON)
		sampler2D _MaskTex;
		float4 _MaskTex_ST;
	#endif
	#if defined(DETAIL_ON)
		sampler2D _DetailTex;
		float4 _DetailTex_ST;
	#endif
	
	void Frag_AddData(inout half4 color, float4 uv0, float4 uv1)
	{
		#if defined(MASK_ON)
			half4 mask = tex2D(_MaskTex, TRANSFORM_TEX(uv0.zw, _MaskTex));
		#endif
		
		#if defined(SOFT_MASK)
			color.a *= mask.a;
		#endif
		
		#if defined(DETAIL_ON)
			half4 detailCol = tex2D(_DetailTex, TRANSFORM_TEX(uv1.xy, _DetailTex));
		#endif

		#if defined(_DETAIL_MUL)
			color.rgb = lerp(color.rgb, color.rgb * detailCol.rgb, detailCol.a * mask.r);
		#elif defined(_DETAIL_BLEND)
			color.rgb = lerp(color.rgb, detailCol.rgb, detailCol.a * mask.r);
		#endif

		#if defined(_INTENSITY_ON)
			half3 diff = _IntensitySample.rgb - color.rgb;
			float emit = dot(diff, diff);
			emit = saturate(1 - emit * _IntensityShape);
			emit = 1 + uv1.z * emit;
			color.rgb *= emit.xxx;
		#endif
	}

#endif